function login(){
	$('span[id^="error_"]').html('');
	$("#loginForm").spin();
	$.ajax({
		type : "POST",
		url : '/login',
		data : $("#loginForm").serialize(),
		success : function(response) {
			$("#loginForm").spin(false);
			if (response.status == "FAILURE") {
				for (i = 0; i < response.errorMessageList.length; i++) {
					var item = response.errorMessageList[i];
					$("#loginForm"+" span[id='error_" + response.errorMessageList[i].fieldName+"']").html(
							response.errorMessageList[i].message);
				}
				$.gritter.add({
					title: response.result.title,
					text: response.result.content
				});
			}
			else {
				window.location.href=document.URL;
			}
		},
		error : function(e) {
			alert(e);
		}
	});
}

function logout(){
	window.location.href='/logout';
}